package org.yawnage.framework.server 
{
	import org.yawnage.framework.Broker;
	import org.yawnage.framework.Diplomat;
	import org.yawnage.framework.TransportLayer;
	import org.yawnage.interfaces.framework.IPublisher;
	import org.yawnage.interfaces.framework.IServiceMap;
	import org.yawnage.interfaces.framework.ISubscriber;
	import org.yawnage.interfaces.framework.ITransportLayer;
	 /**
	  * <p>//TODO:To be written</p>
	  * @author Berry Jordaan
	  * @date 2011/09/06 10:21 AM
	  * @copyright  Copyright © Berry/James 2011
	  * @version 1.0.0.0
	  * @description
	  * @history Berry Jordaan on 2011/09/06 10:21 AM: Created
	  */
	public class Publisher extends ServiceMap implements IServiceMap,IPublisher
	{

		//************** Enums **************

		//************** Public *************
		
		//************** Private ************

		private var _internalID	:int;
		
		//************** protected **********
		
		/**
		 * Constructor
		 */
		public function Publisher(name:String)
		{
			super();
			setClassDescription("org.yawnage.framework.server.Publisher");
			_publisherName = name;
		}
		
		/**
		 * useless comment here!
		 */
		override public function dispose():void 
		{
			super.dispose();
		}
		
		/* INTERFACE org.yawnage.base.interfaces.framework.IPublisher */
		
		public function get internalID():Number 
		{
			return _internalID;
		}
		
		public function syndicate(publisher:Publisher, serviceName:String, transportLayer:* = null):void 
		{
			Broker.instance.syndicate(publisher, serviceName, new TransportLayer(transportLayer));
		}

		public function defineServices():void 
		{
			throw new Error("ERROR: You need to override defineServices(). - "+toString());
		}

		public function subscribe(subscriberP:ISubscriber, callBackP:Function, publisherNameP:String, serviceNameP:String, priority:int = 0):void 
		{
			Diplomat.subscribe(subscriberP, callBackP, publisherNameP, serviceNameP, priority);
		}

		public function get key():String 
		{
			return _publisherName;
		}
		
		public function get name():String 
		{
			return _publisherName;
		}
		
		
		
	}
}